#ifndef _SEARCHER_CONFIG_H
#define _SEARCHER_CONFIG_H

#include "stdafx.h"


class SceneBuilderInfo
{
public:
	std::string mModelFileName;
	Box mSceneBox;
	int mResolution;
	int mSimulationDim;
	SceneBuilderInfo();
	SceneBuilderInfo(const std::string modelName, const vector3& boxMin, const vector3& boxMax, int resolution, int simDim);

};

enum JointBoundType
{
	JBT_Amplitude,
	JBT_Phase,
	JBT_Constant,
	JBT_Min,
	JBT_Max,
	JBT_StraightLen1,
	JBT_StraightLen2,
	JBT_HalfRatio,
	JBT_Warp0,
	JBT_Warp1,
	JBT_Warp2,
	JBT_Warp3,
};

enum JointSearchConstraintType
{
	JSCT_Equal,
	JSCT_Negate,
	JSCT_Less,
	JSCT_Greater,
};

class JointSearchConstraint
{
public:
	JointSearchConstraintType mType;
	std::string mRawName1;
	std::string mRawName2;
	JointBoundType mBoundType;
	std::string mJointName1;
	std::string mJointName2;
	int mConstraintToJointIdx;
	int mConstraintedJointIdx;
};

class JointBound
{
public: 
	JointBoundType mType;
	std::string mRawName;
	std::string mJointName;
	double mMinValue;
	double mMaxValue;
	JointBound();
	JointBound(const std::string& tobeParsed, double minValue, double maxValue);
};

class SearcherInfo
{
public:
	int mObjFuncId;
	double mSearchTimeLength;
	double mEnergyBound;
	double mIdxEnergyBounds[10];
	bool mUseDegree;
	bool mbEnergyPrune;
	bool mbCollisionDetection;
	bool mbEvalSecondCycle;
	std::string mCMAInitialPath;
	std::string mCMASignalPath;
	std::vector<JointBound> mJointBounds;
	std::vector<JointSearchConstraint> mJointConstraints;
	std::vector<double> mJointParams;
	SearcherInfo();
	SearcherInfo(int objFuncId, double searchTimeLen);
	void AddJointBound(const JointBound& bound);
	void AddJointBound(const std::string& rawName, double minValue, double maxValue);
	void AddJointConstraint(const JointSearchConstraint& constraint);
	void AddJointConstraint(const std::string& rawName1, const std::string& rawName2, const std::string& type);
};

class SearcherConfig
{
public:
	SearcherConfig();
	~SearcherConfig();
	void Init(const string& filename);
	const SceneBuilderInfo& GetSceneBuilderInfo() const;
	const SearcherInfo& GetSearcherInfo() const;
private:

	void parse(const string& buffer);
	void checkConfigError(const std::vector<string>& tokens, size_t numInput);
	bool parseVector3(const char* Text, vector3& Value) const;
	std::string mConfigFileName;
	SceneBuilderInfo mSceneBuilderInfo;
	SearcherInfo mSearcherInfo;

};

#endif